package com.pxst.bank.mapper;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import com.pxst.bank.resp.AvailableBankListResp;
import com.pxst.bank.resp.BankSearchResp;
import com.pxst.internalReports.req.BankAccountListReq;
import com.pxst.internalReports.resp.BankAccountListResp;
import com.pxst.merchant.resp.MerchantSelectListResp;
import icu.mhb.mybatisplus.plugln.base.mapper.JoinBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pxst.bank.entity.SysAvailableBankEntity;

/** 
* @author yangxy
* @version 创建时间：2023年9月7日 下午4:35:19 
*/
@Mapper
public interface SysAvailableBankMapper extends JoinBaseMapper<SysAvailableBankEntity> {
	/**
	 * 根据卡群ID获取拥有可用银行卡的银行code
	* @author yangxy
	* @version 创建时间：2023年9月7日 下午6:15:04 
	* @param bankCardGroupId
	* @param bankCodeList
	* @param modeList
	* @return
	 */
	@Select(value = "select availableBank.bank_code from sys_available_bank availableBank "
			+ "where exists( "
			+ "	select 1 from sys_bank_card bankCard "
			+ "	where bankCard.available_bank_id = availableBank.id "
			+ "	and bankCard.bank_card_group_id = #{bankCardGroupId} "
			+ "	and bankCard.status = 1 "
			+ "	and bankCard.type = 1 "
			+ "	and bankCard.mode in (#{modeList}) "
			+ ") "
			+ "and availableBank.bank_code in (#{bankCodeList})")
	List<String> getSysAvailableBankCodeList(@Param("bankCardGroupId")Long bankCardGroupId,@Param("bankCodeList")List<String> bankCodeList,@Param("modeList")List<Integer> modeList);

	/**
	 * 查询银行账户监控列表数据
	 * @param bankAccountListReq
	 * @return List<BankAccountListResp>
	 */
	List<BankAccountListResp> getBankAccountList(BankAccountListReq bankAccountListReq);

	/**
	 * 获取总计
	 * @param bankAccountListReq
	 * @return Map<String, BigDecimal>
	 */
	Map<String, BigDecimal> getTotals(BankAccountListReq bankAccountListReq);

	/**
	 * 查询银行列表信息
	 * @return
	 */
	@Select("select " +
			"id,bank_name,bank_code,currency,fi_max,fi_min,fo_max,fo_min,fx_max,fx_min,tr_max,tr_min,reserved_amount,day_treshold,status,note,is_captcha,meta,is_qr,creator,created_at,updater,updated_at " +
			"from sys_available_bank")
	List<BankSearchResp> selectAll();


	/**
	 * 获取所有可用银行数据
	 * @return
	 */
	@Select("SELECT id bankId, bank_code `code`, currency, bank_name `name`, `status`\n" +
			"FROM sys_available_bank\n" +
			"WHERE `status` = 1")
	List<AvailableBankListResp> getBankSelectList();
}
